package com.jh.channel.pojo.fastsilver;


import cn.jh.common.utils.PayUtil;
import org.apache.commons.collections.MapUtils;

import java.io.InputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import static org.springframework.util.StringUtils.hasText;

public class FastSilverUpload implements Serializable {

    private static final long serialVersionUID = 1L;

    //门头照
    private String merchantHead;

    //收银台照
    private String merchantCheck;

    //经营场所照
    private String otherPhoto3;

    //法人身份证正面照
    private String identityFace;

    //法人身份证反面照
    private String identityBack;

    //开户许可证照
    private String bussinessCard;

    //营业执照照片
    private String bussiness;

    //结算人身份证正面照
    private String identityFaceCopy;

    //结算人身份证反面照
    private String identityBackCopy;

    //手持身份证照片
    private String identityBody;

    //非法人对私授权函
    private String otherPhoto4;

    //租房合同
    private String otherPhoto2;

    //其他资料
    private String otherPhoto;

    //银行卡正面照
    private String cardFace;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getMerchantHead() {
        return merchantHead;
    }

    public void setMerchantHead(String merchantHead) {
        this.merchantHead = merchantHead;
    }

    public String getMerchantCheck() {
        return merchantCheck;
    }

    public String getCardFace() {
        return cardFace;
    }

    public void setCardFace(String cardFace) {
        this.cardFace = cardFace;
    }

    public void setMerchantCheck(String merchantCheck) {
        this.merchantCheck = merchantCheck;
    }

    public String getOtherPhoto3() {
        return otherPhoto3;
    }

    public void setOtherPhoto3(String otherPhoto3) {
        this.otherPhoto3 = otherPhoto3;
    }

    public String getIdentityFace() {
        return identityFace;
    }

    public void setIdentityFace(String identityFace) {
        this.identityFace = identityFace;
    }

    public String getIdentityBack() {
        return identityBack;
    }

    public void setIdentityBack(String identityBack) {
        this.identityBack = identityBack;
    }

    public String getBussinessCard() {
        return bussinessCard;
    }

    public void setBussinessCard(String bussinessCard) {
        this.bussinessCard = bussinessCard;
    }

    public String getBussiness() {
        return bussiness;
    }

    public void setBussiness(String bussiness) {
        this.bussiness = bussiness;
    }

    public String getIdentityFaceCopy() {
        return identityFaceCopy;
    }

    public void setIdentityFaceCopy(String identityFaceCopy) {
        this.identityFaceCopy = identityFaceCopy;
    }

    public String getIdentityBackCopy() {
        return identityBackCopy;
    }

    public void setIdentityBackCopy(String identityBackCopy) {
        this.identityBackCopy = identityBackCopy;
    }

    public String getIdentityBody() {
        return identityBody;
    }

    public void setIdentityBody(String identityBody) {
        this.identityBody = identityBody;
    }

    public String getOtherPhoto4() {
        return otherPhoto4;
    }

    public void setOtherPhoto4(String otherPhoto4) {
        this.otherPhoto4 = otherPhoto4;
    }

    public String getOtherPhoto2() {
        return otherPhoto2;
    }

    public void setOtherPhoto2(String otherPhoto2) {
        this.otherPhoto2 = otherPhoto2;
    }

    public String getOtherPhoto() {
        return otherPhoto;
    }

    public void setOtherPhoto(String otherPhoto) {
        this.otherPhoto = otherPhoto;
    }

    @Override
    public String toString() {
        return "FastSilverUpload{" +
                "merchantHead='" + merchantHead + '\'' +
                ", merchantCheck='" + merchantCheck + '\'' +
                ", otherPhoto3='" + otherPhoto3 + '\'' +
                ", identityFace='" + identityFace + '\'' +
                ", identityBack='" + identityBack + '\'' +
                ", bussinessCard='" + bussinessCard + '\'' +
                ", bussiness='" + bussiness + '\'' +
                ", identityFaceCopy='" + identityFaceCopy + '\'' +
                ", identityBackCopy='" + identityBackCopy + '\'' +
                ", identityBody='" + identityBody + '\'' +
                ", otherPhoto4='" + otherPhoto4 + '\'' +
                ", otherPhoto2='" + otherPhoto2 + '\'' +
                ", otherPhoto='" + otherPhoto + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FastSilverUpload that = (FastSilverUpload) o;
        return Objects.equals(merchantHead, that.merchantHead) &&
                Objects.equals(merchantCheck, that.merchantCheck) &&
                Objects.equals(otherPhoto3, that.otherPhoto3) &&
                Objects.equals(identityFace, that.identityFace) &&
                Objects.equals(identityBack, that.identityBack) &&
                Objects.equals(bussinessCard, that.bussinessCard) &&
                Objects.equals(bussiness, that.bussiness) &&
                Objects.equals(identityFaceCopy, that.identityFaceCopy) &&
                Objects.equals(identityBackCopy, that.identityBackCopy) &&
                Objects.equals(identityBody, that.identityBody) &&
                Objects.equals(otherPhoto4, that.otherPhoto4) &&
                Objects.equals(otherPhoto2, that.otherPhoto2) &&
                Objects.equals(otherPhoto, that.otherPhoto);
    }

    @Override
    public int hashCode() {
        return Objects.hash(merchantHead, merchantCheck, otherPhoto3, identityFace, identityBack, bussinessCard, bussiness, identityFaceCopy, identityBackCopy, identityBody, otherPhoto4, otherPhoto2, otherPhoto);
    }

    public void transform(Map<String,String> pram) {
        setMerchantHead(MapUtils.getString(pram,"merchantHead"));
        setMerchantCheck(MapUtils.getString(pram,"merchantChech"));
        setOtherPhoto3(MapUtils.getString(pram,"otherPhotoThree"));
        setIdentityFace(MapUtils.getString(pram,"identityFace"));
        setIdentityBack(MapUtils.getString(pram,"identityBack"));
        setBussinessCard(MapUtils.getString(pram,"businessCard"));
        setBussiness(MapUtils.getString(pram,"business"));
        setIdentityFaceCopy(MapUtils.getString(pram,"identityFaceCopy"));
        setIdentityBackCopy(MapUtils.getString(pram,"identityBackCpoy"));
        setIdentityBody(MapUtils.getString(pram,"identityBody"));
        setOtherPhoto4(MapUtils.getString(pram,"otherPhotoFour"));
        String otherPhotoTwo = MapUtils.getString(pram,"otherPhotoTwo");
        String otherPhoto = MapUtils.getString(pram,"otherPhoto");
        setCardFace(MapUtils.getString(pram,"cardFace"));
        if (hasText(otherPhoto) && !otherPhoto.equals("null")) {
            setOtherPhoto(otherPhoto);
        }
        if (hasText(otherPhotoTwo) && !otherPhotoTwo.equals("null")) {
            setOtherPhoto2(otherPhotoTwo);
        }
    }


    public Map<String,Object> addMap() {
        Map<String,Object> map = new HashMap<>();
        InputStream pis = PayUtil.getLinkInputStream(getMerchantHead());

        InputStream merchantCheck = PayUtil.getLinkInputStream(getMerchantCheck());
        InputStream otherPhoto3 = PayUtil.getLinkInputStream(getOtherPhoto3());
        InputStream identityFace = PayUtil.getLinkInputStream(getIdentityFace());
        InputStream identityBack = PayUtil.getLinkInputStream(getIdentityBack());
        InputStream bussinessCard = PayUtil.getLinkInputStream(getBussinessCard());
        InputStream bussiness = PayUtil.getLinkInputStream(getBussiness());
        InputStream identityFaceCopy = PayUtil.getLinkInputStream(getIdentityFaceCopy());
        InputStream identityBackCopy = PayUtil.getLinkInputStream(getIdentityBackCopy());
        InputStream identityBody = PayUtil.getLinkInputStream(getIdentityBody());
        InputStream otherPhoto4 = PayUtil.getLinkInputStream(getOtherPhoto4());
        InputStream cardFace = PayUtil.getLinkInputStream(getCardFace());
        if (hasText(getOtherPhoto2())) {
            InputStream otherPhoto2 = PayUtil.getLinkInputStream(getOtherPhoto2());
            map.put("otherPhoto2",otherPhoto2);
        }

        if (hasText(getOtherPhoto())) {
            InputStream otherPhoto = PayUtil.getLinkInputStream(getOtherPhoto());
            map.put("otherPhoto",otherPhoto);
        }
        map.put("merchantHead",pis);
        map.put("merchantCheck",merchantCheck);
        map.put("otherPhoto3",otherPhoto3);
        map.put("identityFace",identityFace);
        map.put("identityBack",identityBack);
        map.put("bussinessCard",bussinessCard);
        map.put("bussiness",bussiness);
        map.put("identityFaceCopy",identityFaceCopy);
        map.put("identityBackCopy",identityBackCopy);
        map.put("identityBody",identityBody);
        map.put("otherPhoto4",otherPhoto4);
        map.put("cardFace",cardFace);

        return map;
    }
}
